import {baseUrl} from "@/config/env";

export default () => {
    return {
        submitText: '修改',
        size: 'default',
        labelWidth: 120,
        labelAlign: "right",
        align: "center",
        index: true,
        menuAlign: 'center',
        menuPosition: "right",
        searchIndex: 2,
        searchMenuSpan: 6,
        searchIcon: true,
        permissionBtn: {
            addBtn: 'sys:dict:item:add',
            editBtn: 'sys:dict:item:edit',
            viewBtn: 'sys:dict:item:info',
            delBtn: 'sys:dict:item:delete',
        },
        column: [
            {
                label: '父级字典',
                span: 24,
                prop: 'parentId',
                addDisplay: true,
                editDisplay: true,
                showColumn: true,
                type: "tree",
                dicUrl: baseUrl + "/start/sysDictionaryItem/listByDictionaryCode",
                dicQuery: {
                    dictCode: null
                },
                props: {
                    label: 'dictName',
                    value: 'id',
                },
                option: {
                    filterText: "搜索关键字",
                }
            },
            {
                label: '名称',
                span: 24,
                prop: 'dictName',
                rules: [{
                    required: true,
                    trigger: "blur"
                }]
            },
            {
                label: '字典类型',
                span: 24,
                prop: 'sysFlag',
                type: 'radio',
                display: false,
                dicData: [
                    {label: "系统字典", value: true},
                    {label: "用户字典", value: false},
                ],
                control: function (value, form, $result, column) {
                    let show = !!value
                    let result = {}
                    result["dictVal"] = {editDetail: show}
                    return result;
                },
            },
            {
                label: '字典值',
                span: 24,
                prop: 'dictVal',
                type: 'textarea',
                maxlength: 255,
                showWordLimit: true,
                rules: [{
                    required: true,
                    trigger: "blur"
                }]
            },

            {
                label: '标签',
                span: 24,
                prop: 'tag',
                type: 'radio',
                control: function (value, form, $result, column) {
                    let show = !!value
                    let result = {}
                    result["tagProp.tagType"] = {display: show}
                    result["tagProp.tagHit"] = {display: show}
                    result["tagProp.tagColor"] = {display: show}
                    result["tagProp.tagSize"] = {display: show}
                    result["tagProp.tagEffect"] = {display: show}
                    result["tagProp.tagRound"] = {display: show}
                    return result;
                },
                dicData: [
                    {label: "否", value: false},
                    {label: "是", value: true},
                ]
            },
            {
                label: '标签类型',
                span: 12,
                prop: 'tagProp.tagType',
                bind: "tagProp.tagType",
                type: 'radio',
                tag: true,
                tagProp: function (val, row, column) {
                    let prop = row.tagProp;
                    let result = {};
                    result.type = val;
                    result.hit = prop["tagHit"];
                    result.color = prop["tagColor"];
                    result.size = prop["tagSize"];
                    result.effect = prop["tagEffect"];
                    result.round = prop["tagRound"];
                    return result
                },
                dicData: [
                    {label: "自动", value: "primary"},
                    {label: "绿色", value: "success"},
                    {label: "灰色", value: "info"},
                    {label: "黄色", value: "warning"},
                    {label: "红色", value: "danger"},
                ],

            },
            {
                label: '文字颜色',
                span: 12,
                prop: 'tagProp.tagColor',
                bind: "tagProp.tagColor",
                type: 'color',
                hide: true,
            },
            {
                label: 'tagEffect',
                span: 12,
                prop: 'tagProp.tagEffect',
                bind: "tagProp.tagEffect",
                type: 'radio',
                hide: true,
                dicData: [
                    {label: "dark", value: "dark"},
                    {label: "light", value: "light"},
                    {label: "plain", value: "plain"},
                ],
            },
            {
                label: '边框描边',
                span: 12,
                prop: 'tagProp.tagHit',
                bind: "tagProp.tagHit",
                type: 'radio',
                hide: true,
                dicData: [
                    {label: "否", value: false},
                    {label: "是", value: true},
                ],
            },

            {
                label: '标签大小',
                span: 12,
                prop: 'tagProp.tagSize',
                bind: "tagProp.tagSize",
                type: 'radio',
                hide: true,
                dicData: [
                    {label: "大", value: "large"},
                    {label: "默认", value: "default"},
                    {label: "小", value: "small"},
                ],

            },

            {
                label: '是否圆形',
                span: 12,
                prop: 'tagProp.tagRound',
                bind: "tagProp.tagRound",
                type: 'radio',
                hide: true,
                dicData: [
                    {label: "否", value: false},
                    {label: "是", value: true},
                ],
            },
            {
                label: '状态',
                span: 24,
                prop: 'disabled',
                type: 'switch',
                tag: true,
                tagProp: {
                    'true': {type: "info"},
                    'false': {type: "primary"}
                },
                dicData: [
                    {label: "禁用", value: true},
                    {label: "启用", value: false},
                ]
            },
            {
                label: '序号',
                span: 24,
                prop: 'dictSort',
                type: 'number',
            },
            {
                label: '描述',
                span: 24,
                prop: 'dictDesc',
                search: true,
                type: "textarea",
                maxLength: 100,
                addDisplay: true,
                editDetail: true,
            },

        ]
    }
}
